#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e3+100;
typedef long long LL;
typedef pair<LL,LL>P;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL dp[maxn],dis[maxn];
bool vis[maxn];
struct Edge{
    LL to,cost;
};
vector<Edge>g[maxn];
LL map1[maxn][maxn];
void dijkstra(LL s){
    memset(dis,0x3f,sizeof(dis));
    LL st=s;
    dis[st]=0;
    priority_queue< P, vector<P> ,greater<P> >que;
    que.push({dis[st],st});
    while(!que.empty()){
        P now=que.top();que.pop();
        LL u=now.second;
        if(vis[u]) continue;
        vis[u]=true;
        for(LL i=0;i<g[u].size();i++){
            Edge e=g[u][i];
            LL to=e.to;LL cost=e.cost;
            if(dis[to]>dis[u]+cost){
                dis[to]=dis[u]+cost;
                dp[to]=dp[u];
                que.push({dis[to],to});
            }
            else if(dis[to]==dis[u]+cost){
                dp[to]+=dp[u];
            }
        }
    }
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL n,m;cin>>n>>m;
  dp[1]=1;
  memset(map1,0x3f,sizeof(map1));
  for(LL i=1;i<=m;i++){
    LL u,v,cost;cin>>u>>v>>cost;
    map1[u][v]=min(map1[u][v],cost);
  }
  for(LL i=1;i<=n;i++){
    for(LL j=1;j<=n;j++){
        if(map1[i][j]!=0x3f3f3f3f3f3f3f3f){
            g[i].push_back({j,map1[i][j]});
        }
    }
  }
  dijkstra(1);
  if(dis[n]==0x3f3f3f3f3f3f3f3f){
    cout<<"No answer"<<"\n";
  }
  else cout<<dis[n]<<" "<<dp[n]<<"\n";
return 0;
}
